<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    function fun(arr) {
        var res = [];
        for (let i = 0; i < arr.length; i++) {
            if (res.indexOf(arr[i]) == res.lastIndexOf(arr[i])) {
                res.push(arr[i]);
            }
        }
        return res;
    }
    console.log(fun([1, 2, 1, 2, 1, 3, 2, 3, 3, 3, 3]));


    function LazyPig(param) {
        console.log("Hello,I'm " + param);
        let obj = {
            time: 0,
            sleep: function (t) {
                setTimeout(() => {
                    console.log("Wake up after " + t);
                }, (t + this.time) * 1000);
                this.time += t;
                return obj;
            },
            eat: function (data) {
                setTimeout(() => {
                    console.log("Eat " + data);
                }, this.time * 1000);
                return obj;
            }
        }
        return obj;
    }
    LazyPig('peiqi').eat('milk').eat('apple').sleep(2).sleep(3).eat('lunch').sleep(3).eat('dinner')

</script>

</html>